using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PACKETPARSERMAX20.CORE
{
    public class command : MangosBase
    {
        public System.String name;
        public System.Byte? security;
        public System.String help;




        public override string GetInsertCommand()
        {
            return string.Format("INSERT IGNORE INTO `command` (`name`, `security`, `help`) VALUES ('{0}', '{1}', '{2}');", name.MySQLDBString(), security.GetValueOrDefault(), help.MySQLDBString());
        }


        public override string GetUpdateCommand()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("UPDATE `command` SET ");
            if (security != null)
            {
                sb.AppendLine("`security`='" + security.Value.ToString() + "'");
            }
            if (help != null)
            {
                sb.AppendLine("`help`='" + help.MySQLDBString() + "'");
            }
            sb = sb.Replace("\r\n", ", ");
            sb.Append(" WHERE `name`='" + name.MySQLDBString() + "';");
            sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
        }


    }
}
